<template>
  <div class="app-container">
 
 <div style="margin-bottom:5px">
  <el-input v-model="input" placeholder="请输入要查找的题目" size='small' style="width:30%"></el-input>
  <el-button type="primary" size="small">查找</el-button>
  </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row 
      size="small">
      <el-table-column align="center" label="ID" width="35">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="题目">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="上传教师" width="110" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.author }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="题型" width="110" align="center">
        <template slot-scope="scope">
          <el-tag :type="deleted">{{ scope.row.status | statusFilter  }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="上传时间" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"/>
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
  background
  layout="prev, pager, next"
  :total="1000">
</el-pagination>
  </div>
</template>

<script>
import { getList } from '@/api/table'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: '选择题',
        draft: '判断题',
        deleted: '红烧蹄'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      input:'',
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getList(this.listQuery).then(response => {
        this.list = response.data.items
        this.listLoading = false
      })
    }
  }
}
</script>
